package com.example.myadmin.common.config;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class MyWebConfig implements WebMvcConfigurer {
    @Autowired
    @Qualifier(value = "loginInterceptor")
    private HandlerInterceptor loginInterceptor;

    //    配置拦截器的方法
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(loginInterceptor);
        //拦截请求
         interceptorRegistration.addPathPatterns("/**");
        //放行请求
//        webjars/** :jquery的路径
        interceptorRegistration.excludePathPatterns("/user/login","/user/logout","/login","/layui/**","/lib/**","/webjars/**","/captcha","/css/**","/images/**","/api/**","/js/**");
    }
}
